package com.xxx.video.main.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.xxx.video.R;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.adapters.BaseViewHolder;
import com.xxx.video.commen.utils.ResourcesUtils;
import com.xxx.video.commen.utils.StringUtils;
import com.xxx.video.main.beans.FriendMessageBean;

import butterknife.BindView;

public class FriendMessageListAdapter extends BaseRecycleViewAdapter<FriendMessageBean.PageBean.ListBean, FriendMessageListAdapter.MyHolder> {


    public FriendMessageListAdapter(@NonNull Context context) {
        super(context);
    }

    @Override
    public MyHolder onCreateDefaultViewHolder(View view, int viewType) {
        return new MyHolder(view);
    }

    @Override
    public int getItemLayout(int viewType) {
        return R.layout.item_friend_message_list;
    }


    class MyHolder extends BaseViewHolder {

        @BindView(R.id.iv_item_friend_message_list_avatar)
        ImageView ivItemFriendMessageListAvatar;
        @BindView(R.id.iv_item_friend_message_list_name)
        TextView ivItemFriendMessageListName;
        @BindView(R.id.iv_item_friend_message_list_desc)
        TextView ivItemFriendMessageListDesc;
        @BindView(R.id.tv_item_friend_message_list_date)
        TextView tvItemFriendMessageListDate;

        public MyHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData2View(int position) {
            FriendMessageBean.PageBean.ListBean listBean = getItem(position);

            /*
             * avatar
             */
            Glide.with(context).load(ResourcesUtils.getInstance().getImagePath(listBean.fCommtenterPicurl))
                    .apply(new RequestOptions().circleCrop()
                            .placeholder(R.drawable.icon_default_avatar)
                            .error(R.drawable.icon_default_avatar)
                    ).into(ivItemFriendMessageListAvatar);
            /*
             * name
             */
            ivItemFriendMessageListName.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fCommtenterName));
            /*
             * desc
             */
            ivItemFriendMessageListDesc.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fComment));
            /*
             * date
             */
            tvItemFriendMessageListDate.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.fCreateTime));
        }
    }
}
